package com.xtx.air.dao.trade.impl;

import java.util.List;

import com.xtx.air.dao.trade.ITradeDAO;
import com.xtx.air.dataobject.TradeDO;
import com.xtx.dao.BaseDAOImpl;

public class TradeDAOImpl extends BaseDAOImpl implements ITradeDAO {

	private static final long DEFAULT_MAX_DAILY_NUM = 0L;

	@Override
	public void addTrade(TradeDO tradeDO) {
		executeInsert("INSERT-TRADE", tradeDO);
	}

	@Override
	public List<TradeDO> findTrade(TradeDO tradeDO) {
		return executeQueryForList("SELECT-TARDE", tradeDO);
	}

	@Override
	public boolean updateTrade(TradeDO tradeDO) {
		return executeUpdate("UPDATE-TRADE", tradeDO) == 1;
	}

	@Override
	public Long getMaxDailyNum() {
		Object obj = this.getSqlMapClientTemplate().queryForObject("SELECT-MAX-DAILY-NUM");
		try {
			return Long.parseLong(String.valueOf(obj));
		} catch (NumberFormatException e) {
			return DEFAULT_MAX_DAILY_NUM;
		}
	}

}